package com.hivekion.goods.controller;

import com.hivekion.common.annotation.AutoLog;
import com.hivekion.common.entity.PagedResultVo;
import com.hivekion.common.enums.OperationTypeEnum;
import com.hivekion.goods.domain.vo.CreateGoodInputVo;
import com.hivekion.goods.domain.vo.GoodSearchInputVo;
import com.hivekion.goods.domain.vo.GoodViewVo;
import com.hivekion.goods.service.IGoodService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 商品管理
 */
@RestController
@RequestMapping("/ele/good")
public class GoodController {

    @Resource
    private IGoodService goodService;


    @PostMapping("/getList")
    @AutoLog(value = "分页获取商品列表", operationType = OperationTypeEnum.SELECT, module = "商品管理/分页获取商品列表")
    public PagedResultVo<GoodViewVo> getList(@RequestBody GoodSearchInputVo vo) {
        return goodService.getList(vo);
    }

    @PostMapping("/add")
    @AutoLog(value = "发布商品", operationType = OperationTypeEnum.INSERT, module = "商品管理/发布商品")
    public boolean add(@RequestBody CreateGoodInputVo inputVo) {
        return goodService.add(inputVo);
    }

}
